﻿<%@ Page Title="" Language="C#" MasterPageFile="/Common/Master.master" %>

<script runat="server">

</script>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentForm" runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentHtml" runat="Server">
    <div class="easyui-layout tableEdit" data-options="fit:true,border:false">
        <div data-options="region:'center',border:false" id="validation" class="validationEngineContainer">
            <div class="z_wrap">
                <ul class="info">
                    <li>
                        <em class='l_name'>guid：</em>
                        <div class='r_con1'>
                            <input id='ID' name='ID' type='text' class='validate[required]' data-prompt-position='bottomRight' /></div>
                    </li>
                    <li>
                        <em class='l_name'>部门ID：</em>
                        <div class='r_con1'>
                            <input id='dept_id' name='dept_id' type='text' class='validate[required]' data-prompt-position='bottomRight' /></div>
                    </li>
                    <li>
                        <em class='l_name'>部门名称：</em>
                        <div class='r_con1'>
                            <input id='name' name='name' type='text' class='validate[required]' data-prompt-position='bottomRight' /></div>
                    </li>
                    <li>
                        <em class='l_name'>父级部门ID：</em>
                        <div class='r_con1'>
                            <input id='parent_id' name='parent_id' type='text' class='validate[required]' data-prompt-position='bottomRight' /></div>
                    </li>
                    <li>
                        <em class='l_name'>部门唯一标识：</em>
                        <div class='r_con1'>
                            <input id='source_identifier' name='source_identifier' type='text' class='validate[required]' data-prompt-position='bottomRight' /></div>
                    </li>
                    <li>
                        <em class='l_name'>排序：</em>
                        <div class='r_con1'>
                            <input id='parent_order' name='parent_order' type='text' class='validate[required]' data-prompt-position='bottomRight' /></div>
                    </li>
                    <li>
                        <em class='l_name'>：</em>
                        <div id='AddTime' class='r_con1'>自动</div>
                    </li>
                    <li>
                        <em class='l_name'>：</em>
                        <div class='r_con1'>
                            <input id='OrgID' name='OrgID' type='text' class='validate[required]' data-prompt-position='bottomRight' /></div>
                    </li>
                </ul>
            </div>
        </div>
        <div data-options="region:'south'" style="height: 35px; border-bottom: 0px; border-left: 0px; border-right: 0px;" class="edit_bottom">
            <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-save'" id="buttonOk">确 定</a>
            <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="$.layerClose(false);">取 消</a>
        </div>
    </div>

    <script type="text/javascript">
        $(function () {
            jQuery('#validation').validationEngine();

            $("#buttonOk").click(function () {
                InsertOrUpdate();
            });
            if ($.getUrlParamer("guid") != "") {
                DataBind();
            }
        });

        function DataBind() {
            $.InvokeAjax({
                url: "Api/V1/dd_dep/Getdep",
                data: { ID: $.getUrlParamer("guid") },
                callBack: function (data) {
                    var obj = $.StrToJson(data).Results;

                    $.SetValue("ID", obj.ID);
                    $.SetValue("dept_id", obj.dept_id);
                    $.SetValue("name", obj.name);
                    $.SetValue("parent_id", obj.parent_id);
                    $.SetValue("source_identifier", obj.source_identifier);
                    $.SetValue("parent_order", obj.parent_order);
                    $.SetValue("AddTime", obj.AddTime);
                    $.SetValue("OrgID", obj.OrgID);

                }
            });
        }

        function InsertOrUpdate() {
            if (!$('#validation').validationEngine('validate')) { return false; }
            var url = $.getUrlParamer("guid") != "" ? "Api/V1/dd_dep/Updatedep" : "Api/V1/dd_dep/Adddep";

            var obj = { ID: $.getUrlParamer("guid") };
            obj.ID = $.GetValue("ID");
            obj.dept_id = $.GetValue("dept_id");
            obj.name = $.GetValue("name");
            obj.parent_id = $.GetValue("parent_id");
            obj.source_identifier = $.GetValue("source_identifier");
            obj.parent_order = $.GetValue("parent_order");
            obj.AddTime = $.GetValue("AddTime");
            obj.OrgID = $.GetValue("OrgID");


            $.InvokeAjax({
                url: url,
                data: obj,
                callBack: function (data) {
                    $.layerClose(true);
                }
            });
        }
    </script>
</asp:Content>
